DAY2:String ends with?


Posted by birdbirdmurmur on 2023-07-15

題目連結:

解題過程:

  • 第一個想法是直接用includes(),以為可以輕鬆通過
    • 原以為includes()無法判斷string
      • 有想過要不要先判斷型態
    • 被自己笨死,看錯題目(請好好練英文x
  • 搞懂題目之後,翻開MDN字典
    • 使用endsWith()可快速判斷字串的結尾
      • 可以區分大小寫
  • Done.

解法:

function solution(str, ending){
  return str.endsWith(ending);
}

參考資料:


#javascript #Codewars #endWith







Related Posts

[BE201] 後端中階:簡單會員註冊系統

[BE201] 後端中階:簡單會員註冊系統

每日心得筆記 2020-06-15(一)

每日心得筆記 2020-06-15(一)

[Release Notes] 20200924_v1 - Fix blog post serie checkbox bug & add publish type modal

[Release Notes] 20200924_v1 - Fix blog post serie checkbox bug & add publish type modal


Comments